﻿Imports Newtonsoft.Json

Public Class HolidayManager

    Private manager As SQLManager

    Public Sub New()
        manager = New SQLManager
    End Sub


    Public Function isSpecialHoliday(ByVal value As DateTime) As Boolean


        Dim holArr As List(Of Holiday)
        Dim hol As New Employee
        Dim query As String = "SELECT * FROM `tbl_holiday` WHERE `holiday_date` = '" + value.ToString("yyyy-M-d") + "' AND `type`='0'"
        Dim resultString As String = "" + manager.executeQuery(query)

        holArr = JsonConvert.DeserializeObject(Of List(Of Holiday))(resultString)

        If (resultString = "") OrElse holArr.Count <= 0 Then
            Return False
        ElseIf holArr.Count > 0 Then
            Return True
        End If

        Return False
    End Function

    Public Function isLegalHoliday(ByVal value As DateTime) As Boolean

        Dim holArr As List(Of Holiday)
        Dim hol As New Employee
        Dim query As String = "SELECT * FROM `tbl_holiday` WHERE `holiday_date` = '" + value.ToString("yyyy-M-d") + "' AND `type`='1'"
        Dim resultString As String = "" + manager.executeQuery(query)

        holArr = JsonConvert.DeserializeObject(Of List(Of Holiday))(resultString)

        If (resultString = "") OrElse holArr.Count <= 0 Then
            Return False
        ElseIf holArr.Count > 0 Then
            Return True
        End If

        Return False
    End Function



End Class
